package com.lingchou.cloud.process.client.servicetask;

import com.lingchou.cloud.process.api.enums.CommentTypeEnum;
import com.lingchou.cloud.process.client.util.ThreadLocalUtil;
import com.lingchou.cloud.process.client.service.impl.ProcessModelServiceImpl;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 超时的服务任务监听 {@link ProcessModelServiceImpl#createServiceTask}
 */
@Component(value = "timeServiceTask")
public class TimeServiceTask implements JavaDelegate {
    protected Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public void execute(DelegateExecution execution) {
        log.info("任务超时，流程ID:{}" , execution.getProcessInstanceId());
        //塞进ThreadLocal
        ThreadLocalUtil.putStatus(CommentTypeEnum.TIME_OUT);
    }
}
